<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a="http://richfaces.org/a4j" xmlns:a4j="http://richfaces.org/a4j"
	template="/layout/template_box.xhtml">

	<ui:define name="head">

		<script type="text/javascript">

		</script>

	</ui:define>

	<ui:define name="MenuInterno">
		<ui:include src="/layout/menu_aluno.xhtml" />
	</ui:define>

	<ui:define name="body">

		<h2 class="t_turma">
			<h:outputText value="Destino do aluno" />
		</h2>

		<div id="tamanho_div">

			<a:outputPanel id="pnlForm" ajaxRendered="true">
				<a:form id="formTurmaHome" styleClass="form_confea">
					

						<ol>
							<s:validateAll>
							<li><s:div>
									<p class="tool_alerta">Os campos marcados com * são de
										preenchimento obrigatório.</p>
								</s:div></li>
							<li>
								<fieldset>
									<legend>
										<h:outputText value="Dados da Aluno" />
									</legend>
								</fieldset>
							</li>
							
							<li><s:decorate template="/layout/edit.xhtml" id="decoNome">
									<ui:define name="label">
							Aluno
						</ui:define>
									<h:outputText value="#{destinoHome.aluno.nome}" />

								</s:decorate></li>

					<s:div id="div_campos">
					<li><s:decorate template="/layout/edit.xhtml"
									id="decoTurma">
									<ui:define name="label">
							Turma
						</ui:define>
									<h:selectOneMenu required="true" immediate="true"
										requiredMessage="O campo 'Turma' é obrigatório."
										id="turma" styleClass="Combo" 
										value="#{destinoHome.destino.turma}">
										<s:selectItems value="#{destinoHome.aluno.turmas}"
											var="turma" label="#{turma.nome}"
											noSelectionLabel="Selecione" />
										<s:convertEntity />
 										<a4j:support event="onchange" limitToList="true" reRender="turma"  ignoreDupResponses="true" eventsQueue="default" ajaxSingle="true"  /> 
																		
									</h:selectOneMenu>

								</s:decorate></li>
								
								
								<li><s:decorate template="/layout/edit.xhtml"
									id="decoMotivo">
									<ui:define name="label">
							Destino
						</ui:define>
									<h:selectOneMenu required="true" immediate="true"
										requiredMessage="O campo 'Destino' é obrigatório."
										id="motivo" styleClass="Combo" 
										value="#{destinoHome.destino.motivo}">
										<s:selectItems value="#{factories.motivosDestinos}"
											var="motivo" label="#{motivo}"
											noSelectionLabel="Selecione" />
										<s:convertEntity />
								
 										<a4j:support event="onchange" limitToList="true" reRender="motivo"  ignoreDupResponses="true" eventsQueue="default" ajaxSingle="true"  /> 
										
									</h:selectOneMenu>

								</s:decorate></li>
								
								<li><s:decorate template="/layout/edit.xhtml"
									id="decoComentario">
									<ui:define name="label">
							Comentários
						</ui:define>
									
									<h:inputTextarea styleClass="campo_full" immediate="true" id="comentario" value="#{destinoHome.destino.comentarios}" required="false">
										<a4j:support event="onchange" limitToList="true" reRender="comentario"  ignoreDupResponses="true" eventsQueue="default" ajaxSingle="true"  />
										</h:inputTextarea>
									

								</s:decorate></li>
								</s:div>
								
								
							<a4j:commandButton value="Adicionar" 
								action="#{destinoHome.adicionarDestino}"
								reRender="div_destinos,div_campos" limitToList="true"
								ignoreDupResponses="true" eventsQueue="default" />
					</s:validateAll>
							<s:div id="div_destinos">
								<rich:dataTable value="#{destinos}" var="_destino"
									styleClass="grid_dados" cellpadding="0" cellspacing="0"
									border="0" id="destinosLista" rowClasses="grid_zebra,none">

									<rich:column>
										<f:facet name="header">Turma</f:facet>
										<h:outputText value="#{_destino.turma.nome}" />
									</rich:column>

									<rich:column>
										<f:facet name="header">Motivo</f:facet>
										<h:outputText value="#{_destino.motivo.nome}" />
									</rich:column>
									
									<rich:column style="width:12%">
										<f:facet name="header">Ações</f:facet>
										<span> 											
											<a4j:commandButton value="Excluir" styleClass="excluir2"
												
												action="#{destinoHome.removerDestino}"
												reRender="div_destinos" ajaxSingle="true" limitToList="true"
												ignoreDupResponses="true" eventsQueue="default" />
											
											<a4j:commandButton value="Editar" styleClass="editar2"
												
												action="#{destinoHome.editarDestino}"
												reRender="div_campos" ajaxSingle="true" limitToList="true"
												ignoreDupResponses="true" eventsQueue="default" />
											

										</span>
									</rich:column>

								</rich:dataTable>
							</s:div>
								
							

						</ol>

						<fieldset>
							<h:messages globalOnly="false" styleClass="tool_alerta" />
						</fieldset>

						<a4j:commandLink styleClass="btn" action="#{destinoHome.salvar}" ajaxSingle="true" eventsQueue="default" bypassUpdates="true"
							value="Salvar" reRender="pnlForm" />

					
				</a:form>
			</a:outputPanel>
		</div>
	</ui:define>

</ui:composition>
